#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using T = int;
T rad(); // quick read
const int inf = 0x3f3f3f3f;
#define rf(i, n) for (int i = 1; i <= (n); ++i)
const int max_size = 5 + 100;
const int maxn = 5 + 1e3;

int n, m; // 行，列
int a[maxn][maxn];
int lef[maxn][maxn], rig[maxn][maxn], up[maxn][maxn], dwn[maxn][maxn];

void update(int x, int y) { // x 行 y 列
    a[x][y] ^= 1;
    if (a[x][y] == 1) { // 变成坏点

        for (int i = x; i >= 0 && dwn[i][y] > x; --i) // 上
            dwn[i][y] = x;
        for (int i = x; i <= n + 1 && up[i][y] < x; ++i) // 下
            up[i][y] = x;
        for (int j = y; j >= 0 && rig[x][j] > y; --j) // 左
            rig[x][j] = y;
        for (int j = y; j <= m + 1 && lef[x][j] < y; ++j) // 右
            lef[x][j] = y;
    } else { // 变回好点

        for (int i = x; i >= 0 && dwn[i][y] < dwn[x + 1][y]; --i) // 上
            dwn[i][y] = dwn[x + 1][y];
        for (int i = x; i <= n + 1 && up[i][y] > up[x - 1][y]; ++i) // 下
            up[i][y] = up[x - 1][y];
        for (int j = y; j >= 0 && rig[x][j] < rig[x][y + 1]; --j) // 左
            rig[x][j] = rig[x][y + 1];
        for (int j = y; j <= m + 1 && lef[x][j] > lef[x][y - 1]; ++j) // 右
            lef[x][j] = lef[x][y - 1];
    }
}

void init() {
    memset(a, 0, sizeof(a));
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            up[i][j] = 0;
            dwn[i][j] = n + 1;
            lef[i][j] = 0;
            rig[i][j] = m + 1;
        }
    }
    for (int i = 0; i <= n + 1; ++i) {
        up[i][0] = i, up[i][m + 1] = i;
        dwn[i][0] = i, dwn[i][m + 1] = i;
        lef[i][0] = 0, lef[i][m + 1] = m + 1;
        rig[i][0] = 0, rig[i][m + 1] = m + 1;
    }

    for (int j = 0; j <= m + 1; ++j) {
        up[0][j] = 0, up[n + 1][j] = n + 1;
        dwn[0][j] = 0, dwn[n + 1][j] = n + 1;
        lef[0][j] = j, lef[n + 1][j] = j;
        rig[0][j] = j, rig[n + 1][j] = j;
    }
}

struct d_s {
    int siz;
    int fa[maxn];

    void init(int x) {
        siz = x + 2;
        for (int i = 0; i <= siz; ++i)
            fa[i] = i;
    }

    int find(int x) {
        if (fa[x] == x) return x;
        return fa[x] = find(fa[x]);
    }

    void merge(int v, int u) { // v -> u
        fa[find(v)] = find(u);
    }
} ds;

vector<int> adj[maxn];

int ask(int x, int y) {
    if (a[x][y]) return 0;
    int ret = 0;
    bool bad;
    // 上
    bad = 0;
    ds.init(m);
    for (int i = 0; i <= n + 1; ++i)
        adj[i].clear();
    for (int j = 0; j <= m + 1; ++j)
        adj[up[x][j]].push_back(j); // 邻接表该行记录列信息
    for (int i = x, l = 0, r = m + 1; i > 0; --i) {
        for (auto j : adj[i]) { // 坏点指向下一个可用列
            if (j != y)
                ds.merge(j, j < y ? j + 1 : j - 1);
            else
                bad = 1;
            // printf("visit: row %d col %d to %d\n", i, j, ds.find(j));
        }
        adj[i].clear();
        if (a[i][y]) continue;
        l = max(ds.find(lef[i][y]), lef[x][y] + 1), r = min(ds.find(rig[i][y]), rig[x][y] - 1);
        if ((l == y || r == y) && bad) continue;
        ret = max(ret, (r - l + 1) * (x - i + 1));
        // printf("row: %d %d %d %d\n", i, ret,  l, r);
    }
    // printf("g: %d\n", ret);
    // 下
    bad = 0;
    ds.init(m);
    for (int i = 0; i <= n + 1; ++i)
        adj[i].clear();
    for (int j = 0; j <= m + 1; ++j)
        adj[dwn[x][j]].push_back(j); // 邻接表该行记录列信息
    for (int i = x, l = 0, r = m + 1; i < n + 1; ++i) {
        for (auto j : adj[i]) // 坏点指向下一个可用列
            if (j != y)
                ds.merge(j, j < y ? j + 1 : j - 1);
            else
                bad = 1;
        adj[i].clear();
        if (a[i][y]) continue;
        l = max(ds.find(lef[i][y]), lef[x][y] + 1), r = min(ds.find(rig[i][y]), rig[x][y] - 1);
        if ((l == y || r == y) && bad) continue;
        ret = max(ret, (r - l + 1) * (i - x + 1));
        // printf("row: %d %d %d %d\n", i, ret,  l, r);
    }
    // printf("g: %d\n", ret);

    // 左
    bad = 0;
    ds.init(n);
    for (int j = 0; j <= m + 1; ++j)
        adj[j].clear();
    for (int i = 0; i <= n + 1; ++i)
        adj[lef[i][y]].push_back(i); //
    for (int j = y, u = 0, d = n + 1; j > 0; --j) {
        for (auto i : adj[j]) {
            if (i != x)
                ds.merge(i, (i < x ? i + 1 : i - 1));
            else
                bad = 1;
            // printf("visit: col %d row %d to %d\n", j, i, ds.find(i));
        }
        adj[j].clear();
        if (a[x][j]) continue;
        u = max(ds.find(up[x][j]), up[x][y] + 1), d = min(ds.find(dwn[x][j]), dwn[x][y] - 1);
        if ((u == x || d == x) && bad) continue;
        ret = max(ret, (d - u + 1) * (y - j + 1));
        // printf("col: %d %d %d %d\n", j, ret, u, d);
    }
    // printf("g: %d\n", ret);

    // 右
    bad = 0;
    ds.init(n);
    for (int j = 0; j <= m + 1; ++j)
        adj[j].clear();
    for (int i = 0; i <= n + 1; ++i)
        adj[rig[i][y]].push_back(i); //
    for (int j = y, u = 0, d = n + 1; j < m + 1; ++j) {
        for (auto i : adj[j]) //
            if (i != x)
                ds.merge(i, i < x ? i + 1 : i - 1);
            else
                bad = 1;
        adj[j].clear();
        if (a[x][j]) continue;
        u = max(ds.find(up[x][j]), up[x][y] + 1), d = min(ds.find(dwn[x][j]), dwn[x][y] - 1);
        if ((u == x || d == x) && bad) continue;
        ret = max(ret, (d - u - 1) * (j - y + 1));
    }
    // printf("g: %d\n", ret);
    return ret;
}
char row[maxn];

int main() {
    int T = rad();
    rf(cas, T) {
        n = rad(), m = rad();
        int q = rad();
        init();
        rf(i, n) {
            scanf("%s", row + 1);
            rf(j, m) if (row[j] == '.') update(i, j);
        }
        printf("Case #%d:\n", cas);
        while (q--) {
            int op = rad(), x = rad(), y = rad();
            if (op == 1) {
                update(x, y);
            } else if (op == 2) {
                printf("%d\n", ask(x, y));
            }
        }
    }
}

T rad() {
    T back = 0;
    int ch = 0, posi = 0;
    for (; ch < '0' || ch > '9'; ch = getchar())
        posi = ch ^ '-';
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        back = (back << 1) + (back << 3) + (ch & 0xf);
    return posi ? back : -back;
}

/*
1
5 11 100
#.#######.#
##.#####.##
###.###.###
####.#.####
###########
2 4 6
2 5 6
1 2 3
1 2 9
2 5 6

1 3 1
2 5 6
1 4 2
2 5 6

2
2 3 2
###
##.
2 2 2
2 1 3
4 3 3
###
#.#
#.#
###
2 3 2
1 3 2
2 3 2


*/